package cn.edu.scau.cmi.hekaimin.factoryMethod;

import javafx.fxml.FXML;

import javafx.scene.control.Button;
import cn.edu.scau.cmi.hekaimin.simpleFactoryMethod.Insurance;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;

import javafx.scene.control.TextArea;

import javafx.scene.control.ComboBox;

public class FactoryMethodController {
	@FXML
	private TextArea textArea_1;
	@FXML
	private Button btn_1;
	@FXML
	private ComboBox comboBox;
    
	public void init() {
		ObservableList<String> options = FXCollections.observableArrayList("身体受伤","汽车损坏","人员伤亡", "多种事故");
	    this.comboBox.setItems(options);
		this.comboBox.getSelectionModel().select(0);
	}
	// Event Listener on Button[#btn_1].onAction
	@FXML
	public void showAction(ActionEvent event) {
	    
		Insurance insurance = null;
		switch((String)this.comboBox.getValue()) {
		case "身体受伤":  insurance = new InjuryFactory().getInsurance();break;
		case "汽车损坏":  insurance = new CarDamageFactory().getInsurance();break;
		case "人员伤亡":  insurance = new CasualtyFactory().getInsurance();break;
		case "多种事故":  insurance = new AccidentsFactory().getInsurance();break;
		default: this.textArea_1.setText("创建保险出错!");break;
		}
		this.textArea_1.setText(insurance.getDetail());
	}
}
